﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Forms;
using System.Data.OleDb;
using System.Collections;

namespace CustSign
{
    public partial class frmOption : Form
    {
        Int32 RedValue, GreenValue, BlueValue, intFontSize;
        String strFontName, strWelcome, strFontStyle;
        FontStyle fsFontStyle;
        FontBase FontNow;

        public frmOption()
        {
            InitializeComponent();
        }

        private void hsbColorCHG(object sender, EventArgs e)
        {
            HScrollBar hsbColor = (HScrollBar)sender;

            if (hsbColor.Name == "hsbRed")
            {
                RedValue = hsbColor.Value;
                txtRed.Text = RedValue.ToString();
            }
            else if (hsbColor.Name == "hsbGreen")
            {
                GreenValue = hsbColor.Value;
                txtGreen.Text = GreenValue.ToString();
            }
            else if (hsbColor.Name == "hsbBlue")
            {
                BlueValue = hsbColor.Value;
                txtBlue.Text = BlueValue.ToString();
            }
            
            lblView.ForeColor = Color.FromArgb(RedValue, GreenValue, BlueValue);
        }

        private void frmOption_Load(object sender, EventArgs e)
        {
            FontNow = new FontBase();

            FontNow.FontGet();

            RedValue = FontNow.RedValue;
            hsbRed.Value = RedValue;
            txtRed.Text = RedValue.ToString();

            GreenValue = FontNow.GreenValue;
            hsbGreen.Value = GreenValue;
            txtGreen.Text = GreenValue.ToString();

            BlueValue = FontNow.BlueValue;
            hsbBlue.Value = BlueValue;
            txtBlue.Text = BlueValue.ToString();

            intFontSize = FontNow.intFontSize;
            hsbFontSize.Value = intFontSize;
            txtFontSize.Text = intFontSize.ToString();
            
            lblView.ForeColor = Color.FromArgb(RedValue, GreenValue, BlueValue);

            cmbFontName.DataSource = FontFamily.Families;
            cmbFontName.DisplayMember = "Name";
            cmbFontName.ValueMember = "Name";
            strFontName = FontNow.strFontName;
            cmbFontName.SelectedValue = strFontName;

            cmbFontStyle.Items.Add("Bold");
            cmbFontStyle.Items.Add("Italic");
            cmbFontStyle.Items.Add("Regular");
            cmbFontStyle.Items.Add("Strikeout");
            cmbFontStyle.Items.Add("Underline");

            strFontStyle = FontNow.strFontStyle;
            cmbFontStyle.SelectedText = strFontStyle;
            fsFontStyle = FontNow.fsFontStyleGet(strFontStyle);

            strWelcome = FontNow.strWelcome;
            txtWelcome.Text = strWelcome;
            lblView.Font = new Font(strFontName, intFontSize, fsFontStyle);
            
        }        

        private void hsbFontSizeCHG(object sender, EventArgs e)
        {
            intFontSize = hsbFontSize.Value;
            txtFontSize.Text = intFontSize.ToString();
            lblView.Font = new Font(strFontName, intFontSize, fsFontStyle);
        }

        private void cmbFontNameCHG(object sender, EventArgs e)
        {
            strFontName = cmbFontName.SelectedValue.ToString();
            lblView.Font = new Font(strFontName, intFontSize, fsFontStyle);
        }

        private void cmbFontStyleCHG(object sender, EventArgs e)
        {
            FontNow = new FontBase();
            fsFontStyle = FontNow.fsFontStyleGet((String)cmbFontStyle.SelectedItem);
            lblView.Font = new Font(strFontName, intFontSize, fsFontStyle);
        }        

        private void btSave_Click(object sender, EventArgs e)
        {
            FontNow = new FontBase();

            strWelcome = txtWelcome.Text;
            FontNow.strWelcome = strWelcome;
            FontNow.RedValue = RedValue;
            FontNow.GreenValue = GreenValue;
            FontNow.BlueValue = BlueValue;
            FontNow.strFontName = strFontName;
            FontNow.strFontStyle = strFontStyle;
            FontNow.intFontSize = intFontSize;

            FontNow.FontSave();
        }
    }
}
